{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	{eq name="$id" value="0"}
	<h3 class="pb-3">新增通知</h3>
	{else/}
	<h3 class="pb-3">编辑通知</h3>
	{/eq}
	<table class="layui-table layui-table-form">
		<tr>
			<td class="layui-td-gray">通知标题<font>*</font></td>
			<td>
				<input type="text" name="title" lay-verify="required" lay-reqText="请输入通知标题" placeholder="请输入通知标题" class="layui-input"
			  {notempty name="$note.title" }value="{$note.title}" {/notempty}>
			</td>
			<!--<td class="layui-td-gray">公告分类<font>*</font></td>-->
			<!--<td>-->
				<!--<select name="cate_id" lay-verify="required" lay-reqText="请选择分类">-->
					<!--<option value="">请选择分类</option>-->
					<!--{notempty name="$note.cate_id"}-->
						<!--{volist name=":set_recursion(note_cate())" id="v"}-->
						<!--<option value="{$v.id}" {eq name="$note.cate_id" value="$v.id" }selected{/eq}>{$v.title}</option>-->
						<!--{/volist}-->
					<!--{else/}-->
						<!--{volist name=":set_recursion(note_cate())" id="v"}-->
						<!--<option value="{$v.id}">{$v.title}</option>-->
						<!--{/volist}-->
					<!--{/notempty}-->
				<!--</select>-->
			<!--</td>-->
		</tr>
		<tr>
			<!--<td class="layui-td-gray">展示期间<font>*</font></td>-->
			<!--<td id="date">-->
				<!--<div class="layui-input-inline">-->
					<!--<input type="text" id="start_time" name="start_time" readonly lay-verify="required" lay-reqText="请选择公告展示开始时间" placeholder="请选择时间" class="layui-input" {notempty name="$note.start_time" }value="{$note.start_time | date='Y-m-d'}" {/notempty}>-->
				<!--</div>-->
				<!-- - -->
				<!--<div class="layui-input-inline">-->
					<!--<input type="text" id="end_time" name="end_time" readonly lay-verify="required" lay-reqText="请选择公告展示结束时间" placeholder="请选择时间" class="layui-input" {notempty name="$note.end_time" }value="{$note.end_time | date='Y-m-d'}" {/notempty}>-->
				<!--</div>-->
			<!--</td>-->
			<td class="layui-td-gray">状态<font>*</font></td>
			<td>
				{if condition="$id eq 0"}
				<input type="radio" name="status" value="1" title="正常" checked>
				<input type="radio" name="status" value="0" title="禁用">
				{else/}
				<input type="radio" name="status" value="1" title="正常" {eq name="$note.status" value="1" }checked{/eq}>
				<input type="radio" name="status" value="0" title="禁用" {eq name="$note.status" value="0" }checked{/eq}>
				{/if}
			</td>
		</tr>

		<tr>
			<td class="layui-td-gray" style="vertical-align:top;">通知内容<font>*</font></td>
			<td colspan="3">
				<textarea name="content" placeholder="请输入通知内容" class="layui-textarea" id="container" style="border:0;padding:0">{notempty name="$note.content" }{$note.content}{/notempty}</textarea>
			</td>
		</tr>
	</table>

	<div class="py-3">
		<input type="hidden" name="id" value="{$id}" />
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool','tinymce'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,laydate = layui.laydate;
		//日期范围
		laydate.render({
			elem: '#date',
			range: ['#start_time', '#end_time'],
			rangeLinked:true
		});

		//编辑器初始化
		var editor = layui.tinymce;
		var edit = editor.render({
			selector: "#container",
			images_upload_url: '/api/index/upload/sourse/tinymce',//图片上传接口
			height: 500
		});
		
		//监听提交
		form.on('submit(webform)', function (data) {
			data.field.content = tinyMCE.editors['container'].getContent();
			if (data.field.content == '') {
				layer.msg('请先完善通知内容');
				return false;
			}
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					tool.sideClose(1000);
				}
			}
			tool.post("/note/index/add", data.field, callback);
			return false;
		});
}
</script>
{/block}
<!-- /脚本 -->